﻿#include "DxLib.h"
#include "Mouse.h"

//メニュータグ
typedef struct {
	int x,y;
	char name[100];
	int over_x;
	int over_y;
	int MenuKazu;
	int Select;
	int Play;
}MENU;


//メニュータグに代入
MENU MenuTag[2][2]={{
	{100 , 350 , "はじめる" , 160 , 30, 2 , 0 , 0 },
	{400 , 350 , "操作方法" , 160 , 30 , 2 , 0 , 0 },
}
};


//定義
static int S_Click = 0;		//音　クリック
static int G_Menu = 0;		//画像　メニューのバック
static int S_Select = 0;	//音　選択



//メニュータグの初期化-----------------------------------------------------------------------------------------------------------------------------
void MenuTag_Init()
{
	//ロード

	S_Click = LoadSoundMem("dat/音/click.wav");
	G_Menu = LoadGraph("dat/画像/menuback.png");
	S_Select = LoadSoundMem("dat/音/select.ogg");
	ChangeVolumeSoundMem(100,S_Select);
}



//メニュータグを表示し、選択したかまでチェック----------------------------------------------------------------------------------------------------------------
int ClacDrawMenuTag(int number , int Color , int Font)
{
	int i=0;

	
	for(i=0;i<MenuTag[number][i].MenuKazu;i++){

		//計算フェーズ----------------------------------------------------------------------------------------------------------
		if(ClickMousePoint(MenuTag[number][i].x ,MenuTag[number][i].over_x , MenuTag[number][i].y , MenuTag[number][i].over_y , FALSE , FALSE)==1){

			if(MenuTag[number][i].Play==0){
				PlaySoundMem( S_Select,DX_PLAYTYPE_BACK);
				MenuTag[number][i].Play=1;
			}
			
			MenuTag[number][i].Select=TRUE;

		}else{
			MenuTag[number][i].Play=0;
			MenuTag[number][i].Select=FALSE;
		}

		if(ClickMousePoint(MenuTag[number][i].x ,MenuTag[number][i].over_x , MenuTag[number][i].y , MenuTag[number][i].over_y , TRUE , S_Click )==1){
			return i;
		}



		//描写フェーズ-----------------------------------------------------------------------------------------------------------

		switch(MenuTag[number][i].Select){

			case FALSE:

				DrawGraph(MenuTag[number][i].x-40 , MenuTag[number][i].y-10 , G_Menu,TRUE);
				break;
			case TRUE:
				DrawRotaGraph(MenuTag[number][i].x+100 , MenuTag[number][i].y+10 , 1.05 , 0.0 , G_Menu , TRUE);
				break;
		}

		DrawStringToHandle(MenuTag[number][i].x , MenuTag[number][i].y , MenuTag[number][i].name , Color , Font	);

	}


	return 100;
}